package ceha.util;

import ceha.application.CEHA;
import java.io.IOException;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JDialog;

public class OkDialog extends JDialog {

    private final String message;
    private CEHA cehalogin;
    private boolean quit;

    public OkDialog(CEHA cehalogin, String message, boolean quit) {
        this.quit = quit;
        this.message = message;
        this.cehalogin = cehalogin;
        action();
    }

    public OkDialog(String message, boolean quit) {
        this.quit = quit;
        this.message = message;
        action();
    }

    private void action() {
        initComponents();
        messageLabel.setText(message);
//        wamp.setText(cehalogin.getMysqlF());
    }

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        panel = new javax.swing.JPanel();
        annulerButton = new javax.swing.JButton();
        messageLabel = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setAlwaysOnTop(true);

        panel.setBackground(new java.awt.Color(102, 102, 102));

        annulerButton.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        annulerButton.setText("Fermer");
        annulerButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                fermerA(evt);
            }
        });

        messageLabel.setBackground(new java.awt.Color(255, 255, 255));
        messageLabel.setFont(new java.awt.Font("Times New Roman", 1, 14)); // NOI18N
        messageLabel.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
        messageLabel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/ceha/ressource/information.gif"))); // NOI18N
        messageLabel.setBorder(new org.jdesktop.swingx.border.DropShadowBorder());
        messageLabel.setOpaque(true);

        javax.swing.GroupLayout panelLayout = new javax.swing.GroupLayout(panel);
        panel.setLayout(panelLayout);
        panelLayout.setHorizontalGroup(
            panelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(panelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(panelLayout.createSequentialGroup()
                        .addComponent(messageLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 298, Short.MAX_VALUE)
                        .addContainerGap())
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelLayout.createSequentialGroup()
                        .addComponent(annulerButton)
                        .addGap(85, 85, 85))))
        );
        panelLayout.setVerticalGroup(
            panelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(messageLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 38, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(annulerButton)
                .addContainerGap())
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(panel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(panel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );

        java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
        setBounds((screenSize.width-326)/2, (screenSize.height-123)/2, 326, 123);
    }// </editor-fold>//GEN-END:initComponents

    private void fermerA(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_fermerA

        if (quit) {
            System.exit(0);
        } else {
            setVisible(false);
        }
}//GEN-LAST:event_fermerA
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton annulerButton;
    private javax.swing.JLabel messageLabel;
    private javax.swing.JPanel panel;
    // End of variables declaration//GEN-END:variables
}
